

#include<iostream>
#include<vector>
#include<queue>
using namespace std;

char a[10][10] = { false };
bool vis[10][10] = { false };
int ret;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { -1,1,0,0 };

void bfs(int i, int j)
{
    queue<pair<int, int>>q;
    q.push({ i,j });
    vis[i][j] = true;
    while (q.size())
    {
        int i = q.front().first;
        int j = q.front().second;
        q.pop(); ret++;

        for (int k = 0; k < 4; k++)
        {
            int x = i + dx[k]; int y = j + dy[k];
            if (x >= 0 && x < 10 && y >= 0 && y < 10 && vis[x][y] == false && a[x][y] == '0')
            {
                q.push({ x,y });
                vis[x][y] = true;
            }
        }

    }
}

int main()
{
    int x = 0, y = 0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i < 9; i++)
    {
        if (x != 0)break;
        for (int j = 1; j < 9; j++)
        {
            //cin >> a[i][j];
            if (a[i][j] == '0' && a[i - 1][j] == '1' && a[i][j - 1] == '1')
            {
                x = i; y = j;
                break;
            }
        }
    }
    if (x != 0)
        bfs(x, y);

    int m = -1, n = -1;
    for (int i = 8; i >= 1; i--)
    {
        if (m != -1)break;
        for (int j = 8; j >= 1; j--)
        {
            if (a[i][j] == '0' && a[i + 1][j] == '1' && a[i][j + 1] == '1' && vis[i][j] == false)
            {
                m = i; n = j; break;
            }
        }
    }
    if (m != -1)
        bfs(m, n);
    cout << ret << endl;
    return 0;
}
